import {
  Column,
  Entity,
  JoinColumn,
  ManyToOne,
  OneToMany,
  PrimaryGeneratedColumn,
} from 'typeorm';
import { FileUpload } from '@/module/file-upload/entities/file-upload.entity';
import { TestingMachine } from '@/testing-machine/entities/testing-machine.entity';

@Entity()
export class EverydayData {
  @PrimaryGeneratedColumn()
  id: number;

  @ManyToOne(() => TestingMachine, (test) => test.everydayDatas, {
    cascade: true,
  })
  @JoinColumn()
  testingMachine: TestingMachine;

  @OneToMany(() => FileUpload, (file) => file.everydayData, {
    cascade: true,
  })
  fileUploads: FileUpload[];

  @Column({
    type: 'date',
  })
  uploadDate: Date = new Date();

  // 当天所有虫子的数量
  @Column()
  allNumber: number;

  @Column({ type: 'json' })
  otherNumber: any;
}
